﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CheckPoint : MonoBehaviour
{
    public int index = 0;
    public Text Text_Level;
    public GameObject[] stars;

    void Awake()
    {
        
    }

    public void Refresh(LevelData levelData)
    {
        Text_Level.text = "关卡 " + levelData.level1.ToString() + " - " + levelData.level2.ToString();
        
        int starNumber = CommonData.GetStarNumber(levelData.score, levelData.starNumbers);
        SetStars(starNumber);
    }

    //设置星星数量
    void SetStars(int number)
    {
        for (int i = 0; i < stars.Length; i++)
        {
            if(i <= number - 1)
            {
                stars[i].gameObject.SetActive(true);
            }
            else
            {
                stars[i].gameObject.SetActive(false);
            }
        }
    }
}
